package com.yc.tea.api


import com.spit.fammo.bean.BaseResponseBean
import com.spit.fammo.bean.DataBean
import com.spit.fammo.bean.db.AssetBean
import com.spit.fammo.bean.db.ListingBean
import com.spit.fammo.bean.db.StockTakeListBean
import com.spit.fammo.util.CacheUtil
import com.spit.smas.bean.BaseListBean
import okhttp3.ResponseBody
import retrofit2.http.*


/**
 * Created by xuhao on 2017/11/16.
 * Api 接口
 */

interface ApiService{

    companion object {

        private val url =
//            "192.168.2.28"
            "47.243.120.137"

        var SERVLET_URL = "http://" +
                url + "/StandardAMS_V1.1.0_CDSJ_WebService/"

        private const val asmx = "MobileWebService.asmx/"

    }

    //登录
    @FormUrlEncoded
    @POST("$asmx" + "GetCheckLogin")
    suspend fun CheckLogin(
        @Field("loginID") loginID: String,
        @Field("userPwd") userPwd: String,
        @Field("companyID") companyID: String = CacheUtil.getCompanyID()
    ): DataBean

    //用户列表
    @FormUrlEncoded
    @POST("$asmx" + "userList")
    suspend fun userList(
        @Field("userid") userid: String,
        @Field("lastcalldate") lastcalldate: String = "",
        @Field("companyID") companyID: String = CacheUtil.getCompanyID()
    ): BaseResponseBean<List<DataBean>>

    //资产列表
    @FormUrlEncoded
    @POST("$asmx" + "assetsDetail")
    suspend fun assetsDetail(
        @Field("assetno") assetno: String = "",
        @Field("lastcalldate") code: String = "",
        @Field("userid") userid: String = CacheUtil.getUser()!!.userid!!,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): ResponseBody

    //获取类别，地点一二三级 （后台很蠢的写法）
    @FormUrlEncoded
    @POST("$asmx" + "listing")
    suspend fun listing(
        @Field("type") type: Int,//0分类 1位置
        @Field("fatherrono") fatherrono: String?,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): List<ListingBean>

    //盘点清单列表
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeList")
    suspend fun stockTakeList(
        @Field("userid") userid: String = CacheUtil.getUser()!!.userid!!,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): List<StockTakeListBean>

    //盘点清单详情EPC
    @FormUrlEncoded
    @POST("$asmx" + "stockTakeListAsset")
    suspend fun stockTakeListAsset(
        @Field("orderno") orderno: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.userid!!,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): BaseListBean<List<AssetBean>>

    //上传盘点
    @FormUrlEncoded
    @POST("$asmx" + "UploadStockTake")
    suspend fun uploadStockTake(
        @Field("strJson") strJson: String?,
        @Field("userid") userid: String = CacheUtil.getUser()!!.userid!!,
        @Field("companyid") companyid: String  = CacheUtil.getCompanyID()
    ): DataBean

}